#ifndef __STORMWIDGET_STORMWIDGET_UILIBRARY_UIDEFINITION_H
#define __STORMWIDGET_STORMWIDGET_UILIBRARY_UIDEFINITION_H

/////////////////////////////////////////////////////////////////////////////////////
//
#ifndef SAFE_DELETE
#define SAFE_DELETE(p)       {if(p){delete (p);(p)=NULL;}}
#endif

#ifndef SAFE_RELEASE
#define SAFE_RELEASE(p)      {if(p){(p)->Release();(p)=NULL;}}
#endif
/////////////////////////////////////////////////////////////////////////////////////
//
#define lengthof(x) (sizeof(x)/sizeof(*x))
#define MAX max
#define MIN min
#define CLAMP(x,a,b) (MIN(b,MAX(a,x)))

/////////////////////////////////////////////////////////////////////////////////////
//

#define UI_WNDSTYLE_CONTAINER  (0)
#define UI_WNDSTYLE_FRAME      (WS_VISIBLE | WS_OVERLAPPEDWINDOW)
#define UI_WNDSTYLE_CHILD      (WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN)
#define UI_WNDSTYLE_DIALOG     (WS_VISIBLE | WS_POPUPWINDOW | WS_CAPTION | WS_DLGFRAME | WS_CLIPSIBLINGS | WS_CLIPCHILDREN)

#define UI_WNDSTYLE_EX_FRAME   (WS_EX_WINDOWEDGE)
#define UI_WNDSTYLE_EX_DIALOG  (WS_EX_TOOLWINDOW | WS_EX_DLGMODALFRAME)

#define UI_CLASSSTYLE_CONTAINER  (0)
#define UI_CLASSSTYLE_FRAME      (CS_VREDRAW | CS_HREDRAW)
#define UI_CLASSSTYLE_CHILD      (CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS | CS_SAVEBITS)
#define UI_CLASSSTYLE_DIALOG     (CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS | CS_SAVEBITS)


/////////////////////////////////////////////////////////////////////////////////////
//

#define ASSERT(expr)  _ASSERTE(expr)

#ifdef _DEBUG
#define TRACE __Trace
#define TRACEMSG __TraceMsg
#else
#define TRACE
#define TRACEMSG _T("")
#endif

void  __Trace(LPCTSTR pstrFormat, ...);
LPCTSTR __TraceMsg(UINT uMsg);



#endif  __STORMWIDGET_STORMWIDGET_UILIBRARY_UIDEFINITION_H  